 /**********************
 * Matthew Tanner
 * tannerm.onid.orst.edu
 * CS362
 * Assignment #3 unittest1.c
 * Tests the isGameOver function in dominion.c
 ***********************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "rngs.h"
 #include "tests.h"

void unittest1(){

	//set minimum required variables
	struct gameState g;
	int players = 2;
	int k[10] = {adventurer, council_room, sea_hag, gardens, mine, remodel, smithy, village, baron, great_hall};
	int seed = 100;
	int res, numPlayerCards, player;

	//initialize game
	res = initializeGame(players, k, seed, &g);

	printf("Testing isGameOver:\n");

	// Game should not be over at start
	assert(!isGameOver(&g));
	printf("Confirmed game is NOT over at initialization\n");

	// Conditon #1, game is over when stack of Province Cards empty
	printf("Emptying stack of province cards\n");
	g.supplyCount[province] = 0;
	assert(isGameOver(&g));
	if(isGameOver(&g)){
		printf("function confirms game is over\n");
	}
	printf("Province card stack count reset to 1\n");
	g.supplyCount[province] = 1;

	// Condition #2, game is over when 3 supply piles are empty
	// Empty one supply pile and check not over yet
	g.supplyCount[0] = 0;
	assert(!isGameOver(&g));
	if(!isGameOver(&g)){
		printf("Game is not over with one supply pile emptied\n");
	}

	// Empty second supply pile and check not over yet
	g.supplyCount[1] = 0;
	assert(!isGameOver(&g));
	if(!isGameOver(&g)){
		printf("Game is not over with two supply piles emptied\n");
	}

	// Empty third supply pile and check that game is over
	g.supplyCount[2] = 0;
	assert(isGameOver(&g));
	if(isGameOver(&g)){
		printf("Game is over with three supply piles emptied\n");
	}
}